package main.nk.mygraph;

import com.mxgraph.reader.mxGraphViewImageReader;
import com.mxgraph.reader.mxGraphViewReader;
import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.view.mxGraph;
import javafx.application.Application;
import javafx.embed.swing.SwingNode;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.MenuBar;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import org.xml.sax.SAXException;

import javax.xml.parsers.ParserConfigurationException;
import java.awt.image.BufferedImage;
import java.io.IOException;

public class Test6 extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws IOException, SAXException, ParserConfigurationException {

        BorderPane pane = new BorderPane();

        Scene scene = new Scene(pane,599,599);

        mxGraph graph = new mxGraph();
        Object parent = graph.getDefaultParent();
        graph.getModel().beginUpdate();

        try{
            graph.insertVertex(parent,null,"Hello",23,23,40,40);

        }finally {
            graph.getModel().endUpdate();

        }
        mxGraphComponent component = new mxGraphComponent(graph);

       /* mxGraphViewImageReader reder = new mxGraphViewImageReader();
        BufferedImage convert = reder.convert("D:/GitBase/javaFXRepository/Day04/main/resources/images/box.png", reder);
        System.out.println(convert);*/
        component.setDragEnabled(false);
        int width = component.getWidth();

        SwingNode node = new SwingNode();
        System.out.println("画布的宽度" + width);
        node.setContent(component);

        Button b = new Button("ff");
        pane.setCenter(node);
        //pane.setBottom(node);

        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
